# 构建阶段
FROM repo.zjdywl.com/node:20-alpine AS builder

# 设置工作目录
WORKDIR /app

# 复制package.json和package-lock.json(或yarn.lock)
COPY package*.json ./

# 安装依赖
RUN npm install pnpm -g
RUN pnpm install --registry=https://registry.npmmirror.com

# 复制源代码
COPY . .

# 构建应用
RUN pnpm run build

# 生产阶段
FROM repo.zjdywl.com/node:20-alpine AS runner
WORKDIR /app

# 设置环境变量
ENV NODE_ENV production
ENV NEXT_TELEMETRY_DISABLED 1
ENV BASE_PATH /ai-receipt-web

# 从builder阶段复制必要文件
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static

# 暴露端口
EXPOSE 3000

# 启动命令
ENV PORT 3000
CMD ["node", "server.js"] 